﻿using MediatR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HMediatR
{
    public class BaseEntity:IDoMainEvent
    {
        public List<INotification> Events = new List<INotification>();
        /// <summary>
        /// 注册事件
        /// </summary>
        /// <param name="notification"></param>
        public void AddEvent(INotification notification)
        {
            Events.Add(notification);
        }
        /// <summary>
        /// 不重复注册事件
        /// </summary>
        /// <param name="notification"></param>
        public void AddNotExistEvent(INotification notification)
        {
            if (!Events.Contains(notification)) Events.Add(notification);
        }
        /// <summary>
        /// 获取所有注册事件
        /// </summary>
        /// <returns></returns>
        public List<INotification> GetAllEvents()
        {
            return Events;
        }
        /// <summary>
        /// 移除所有事件
        /// </summary>
        public void RemoveEvent()
        {
            Events.Clear();
        }
    }
}
